<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改用户角色</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f8f9fa;
        }
        .container {
            margin-top: 50px;
        }
    </style>
</head>
<body>
<div class="container">
    <h2 class="text-center mb-4">修改用户角色</h2>

    <!-- 如果角色是 'auditor' -->
    {% if cannot_modify %}
        <div class="alert alert-warning text-center">
            无法修改 <strong>审计员 (Auditor)</strong> 角色。
        </div>
        <div class="text-center mt-3">
            <a href="{% url 'user_management' %}" class="btn btn-secondary">返回用户管理</a>
        </div>
    {% else %}
        <form method="POST" action="{% url 'edit_user' user.id %}">
            {% csrf_token %}
            <div class="mb-3">
                <label for="role" class="form-label">角色</label>
                <select id="role" name="role" class="form-control" required>
                    <option value="admin" {% if user.role == "admin" %}selected{% endif %}>管理员 (Admin)</option>
                    <option value="user" {% if user.role == "user" %}selected{% endif %}>普通用户 (User)</option>
                </select>
            </div>
            <div class="d-flex justify-content-between">
                <button type="submit" class="btn btn-primary">保存</button>
                <a href="{% url 'user_management' %}" class="btn btn-secondary">取消</a>
            </div>
        </form>
    {% endif %}
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
